***********************************************************************************************************************************************************************************************************
***********************************************************************************************************************************************************************************************************
**************************************************************************************** REPLICATION FILES ************************************************************************************************
******************************************************************************************   MAIN TEXT   **************************************************************************************************
***********************************************************************************************************************************************************************************************************
***********************************************************************************************************************************************************************************************************



************************************************************************************************************************************************************************************************************
********************************************************************************************** MEANS *******************************************************************************************************
*************************************************************************************************************************************************************************************************************

clear
use "Brancati_isodly_final.dta"

*Footnote 15*
pwcorr co2change  oxfstringindex, sig

*Figure 1a
ttest rebelattk_isodly, by(prelockdown_oxf50)
ttest rebelattk_isodly, by(lockdown_oxf50)
ttest rebelattk_isodly, by(postlastlockdown_oxf50)  
  ttest rebelattk_isodly if (prelockdown_oxf50==1 | postlastlockdown_oxf50==1), by(prelockdown_oxf50)

*Figure 1b
ttest stateattk_isodly, by(prelockdown_oxf50)
ttest stateattk_isodly, by(lockdown_oxf50)  
ttest stateattk_isodly, by(postlastlockdown_oxf50) 
  ttest stateattk_isodly if (prelockdown_oxf50==1 |  postlastlockdown_oxf50==1), by(prelockdown_oxf50)

*In-Text Figure
ttest rebelattkcivln_isodly, by(prelockdown_oxf50)
ttest rebelattkcivln_isodly, by(lockdown_oxf50)  
ttest rebelattkcivln_isodly, by(postlastlockdown_oxf50) 
  ttest stateattk_isodly if (prelockdown_oxf50==1 |  postlastlockdown_oxf50==1), by(prelockdown_oxf50)

  
  
************************************************************************************************************************************************************************************************************
**************************************************************************************** BASELINE MODELS ***************************************************************************************************
************************************************************************************************************************************************************************************************************

clear
use "Brancati_isodly_final.dta"

xtset isonum

*Model 1, Figure 3a: Oxford50 - Short and Long-term (ALL) 
xtpoisson rebelattk_isodly lockdown_oxf50 postlockdown_oxf50nolast postlastlockdown_oxf50  deaths_wklag entrance exit stateattk_isowkly_lag, fe
   test lockdown_oxf50=postlastlockdown_oxf50
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0) predict(nu0)
   margins, at(lockdown_oxf50=1 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0) predict(nu0)
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=1) predict(nu0)


*Model 2, Figure 3b,: Oxford50 - Short and Long-term (ALL) 
xtpoisson stateattk_isodly lockdown_oxf50 postlockdown_oxf50nolast postlastlockdown_oxf50 deaths_wklag entrance exit, fe 
   test lockdown_oxf50=postlastlockdown_oxf50
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0) predict(nu0)
   margins, at(lockdown_oxf50=1 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0) predict(nu0)
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=1) predict(nu0)
  

************************************************************************************************************************************************************************************************************
**************************************************************************************** ECONOMIC MODELS ***************************************************************************************************
*************************************************************************************************************************************************************************************************************
   
clear
use "Brancati_isoqtrly_final.dta"
    
xtset isonum
gen lnrealGDP = ln(realGDP)
gen lnrealGDP_lag = ln(realGDP_lag)
*Note: exit and entrance are not included among the baseline controls due to limited variation in them. 

*************************************
*Economic Factors: Outcome Variables*
*************************************

*Model 3, Figure 3: Predict GDP* 
xtreg lnrealGDP lockdownoxf50_qtrlag postlockdownoxf50nolast_qtrlag postlastlockdownoxf50_qtrlag deaths_wklag, fe 
   margins, at(lockdownoxf50_qtrlag=0 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=0)
   margins, at(lockdownoxf50_qtrlag=1 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=0)
   margins, at(lockdownoxf50_qtrlag=0 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=1)
   
*Model 4, Figure 3: Predict Unemployment*  
xtreg unemploy postlastlockdownoxf50_qtrlag postlockdownoxf50nolast_qtrlag lockdownoxf50_qtrlag deaths_wklag, fe 
   margins, at(lockdownoxf50_qtrlag=0 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=0)
   margins, at(lockdownoxf50_qtrlag=1 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=0)
   margins, at(lockdownoxf50_qtrlag=0 postlockdownoxf50nolast_qtrlag=0 postlastlockdownoxf50_qtrlag=1)
   

************************************
* Outcome: Non-state Actor Violence*
************************************
   

*Model 5, Figure 4a: Predict NSA with GDP*
xtpoisson rebelattk_isodly stateattk_isowkly_lag deaths_wklag lnrealGDP_lag, fe 

*Model 6, Figure 4a: Predict NSA with GDP and Lockdowns*
xtpoisson rebelattk_isodly lockdown_oxf50 postlockdown_oxf50nolast postlastlockdown_oxf50 stateattk_isowkly_lag deaths_wklag lnrealGDP_lag, fe  
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0)
   margins, at(lockdown_oxf50=1 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0)
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=1)
  

*Model 7, Figure 4b: Predict NSA with Unemployment*
xtpoisson rebelattk_isodly stateattk_isowkly_lag deaths_wklag unemploy_lag, fe 

*Model 8, Figure 4b: Predict NSA with Unemployment and Lockdowns*
xtpoisson rebelattk_isodly lockdown_oxf50 postlockdown_oxf50nolast postlastlockdown_oxf50 stateattk_isowkly_lag deaths_wklag unemploy_lag, fe
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0)
   margins, at(lockdown_oxf50=1 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=0)
   margins, at(lockdown_oxf50=0 postlockdown_oxf50nolast=0 postlastlockdown_oxf50=1)
  

*************************************************************************************************************************************************************************************************************
**************************************************************************************** POPULATION MODELS **************************************************************************************************
*************************************************************************************************************************************************************************************************************
  
clear
use "Brancati_admndly_final.dta"
 

*Model 9, Figure 5: Population Density (FE)*
xtset isonum
gen lockdown_oxf50_popdensity000 = lockdown_oxf50*popdensity000
xtpoisson rebelattk_admdly lockdown_oxf50 lockdown_oxf50_popdensity000 popdensity000 popmil sizekm2 stateattk_admwkly_lag deaths_wklag entrance exit state_territory contested_territory, fe
test lockdown_oxf50 lockdown_oxf50_popdensity000 popdensity000

gen esample50 = e(sample)
tabstat rebelattk_admdly if esample50 == 1

margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=0) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=0 popdensity000=0) predict(nu0)

margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=1) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=1 popdensity000=1) predict(nu0)

margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=2) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=2 popdensity000=2) predict(nu0)	

margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=3) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=3 popdensity000=3) predict(nu0)	
  
margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=4) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=4 popdensity000=4) predict(nu0)
 
margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=5) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=5 popdensity000=5) predict(nu0)
  
margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=6) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=6 popdensity000=6) predict(nu0)

margins, at(lockdown_oxf50=0 lockdown_oxf50_popdensity000=0 popdensity000=7) predict(nu0)
margins, at(lockdown_oxf50=1 lockdown_oxf50_popdensity000=7 popdensity000=7) predict(nu0)


** Model 10: Population Density (FE), Non-Citizens (Only) **
gen rebelattknonciv_admdly = rebelattk_admdly-rebelattkcivln_admdly
xtpoisson rebelattknonciv_admdly lockdown_oxf50 lockdown_oxf50_popdensity000 popdensity000 popmil sizekm2 stateattk_admwkly_lag deaths_wklag entrance exit state_territory contested_territory, fe 
test lockdown_oxf50 lockdown_oxf50_popdensity000 popdensity000

	

*************************************************************************************************************************************************************************************************************
**************************************************************************************** ID MODELS **********************************************************************************************************
*************************************************************************************************************************************************************************************************************
  
clear
use "Brancati_isodly_final.dta"
  
xtset isonum

*Generate Sample*
xtpoisson rebelattk_isodly lockdown_oxf50 stateattk_isowkly_lag deaths_wklag entrance exit, fe  
gen sample = e(sample)  

*Model 11: Instrumental Variable [Lockdown 50]*
xtivreg rebelattk_isodly stateattk_isowkly_lag deaths_wklag entrance exit (lockdown_oxf50=sumborder_deaths_wklag abspandistance) if sample ==1, fe i(isonum) first
*Sargan-Hansen Statistic*
xtoverid, cluster (iso) 
*Reduced Form* 
xtreg rebelattk_isodly sumborder_deaths_wklag abspandistance if sample ==1, fe 


*Model 12: IV w/ Additional Controls (GDP and Unemployment)**
gen lnrealGDP_lag = ln(realGDP_lag)
xtivreg rebelattk_isodly stateattk_isowkly_lag deaths_wklag lnrealGDP_lag unemploy_lag (lockdown_oxf50=sumborder_deaths_wklag abspandistance) if sample ==1, fe i(isonum) first
*Sargan-Hansen Statistic*
xtoverid, cluster (iso)
*Reduced Form*  
xtreg rebelattk_isodly sumborder_deaths_wklag abspandistance if sample == 1, fe
